home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume11 / pstext / part01 next >
Encoding:
Text File  |  1990-04-06  |  17.7 KB  |  626 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i101: pstext -a small ascii to postscript converter (1 of 1)
  3. from: danjudd@acc.stolaf.edu (Dan Judd)
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 11, Issue 101
  7. Submitted-by: danjudd@acc.stolaf.edu (Dan Judd)
  8. Archive-name: pstext/part01
  9.  
  10. Please accept this program for submission to comp.sources.misc.
  11. We (St Olaf College) have been using it as the generic laser printer
  12. filter for several months now without a hitch. It has been compiled
  13. on Next's, Sun's, an Ms-Dos machine, and vaxen 11/780 running Mt Xinu 4.3
  14. BSD and has worked on all of them.
  15.  
  16. The shar file follows
  17.  
  18. Dan Judd
  19. -------------cut here------------------
  20. #! /bin/sh
  21. # This is a shell archive, meaning:
  22. # 1. Remove everything above the #! /bin/sh line.
  23. # 2. Save the resulting text in a file.
  24. # 3. Execute the file with /bin/sh (not csh) to create the files:
  25. #    Readme
  26. #    Makefile
  27. #    pstext.1
  28. #    pstext.c
  29. # This archive created: Fri Apr  6 11:46:05 1990
  30. # By:    Dan Judd ()
  31. export PATH; PATH=/bin:$PATH
  32. if test -f 'Readme'
  33. then
  34.     echo shar: will not over-write existing file "'Readme'"
  35. else
  36. cat << \SHAR_EOF > 'Readme'
  37.  
  38. This is yet another turn your postscript printer into a 
  39. line printer kind of program. I wrote this because I wanted a 
  40. plain text filter that would handle tabs and back spaces sanely,
  41. print 2 pages on 1, print lanscape or portrait, and no cutesy 
  42. page headers. It has an option to print x lines per page for those
  43. of you who do not wish to figure out what size of Times-Roman (or
  44. whatever font you like) is needed to get 66 lines per page.
  45.  
  46. Feel free to do what you want with this program, except sell it.
  47. If you find bugs or add neat features that are not specific to
  48. any particular laser printer send me mail.
  49.  
  50. Dan Judd
  51. St. Olaf College
  52. 12/18/1989
  53. danjudd@thor.acc.stolaf.edu
  54. SHAR_EOF
  55. fi # end of overwriting check
  56. if test -f 'Makefile'
  57. then
  58.     echo shar: will not over-write existing file "'Makefile'"
  59. else
  60. cat << \SHAR_EOF > 'Makefile'
  61. CC= /bin/cc
  62. DEST= /usr/local/sto/pstext
  63. PSTEXT_SRC=    pstext.c
  64. PSTEXT_OBJ=    pstext.o
  65.  
  66. all:    $(PSTEXT_OBJ)
  67.     $(CC) -o pstext $(PSTEXT_OBJ)
  68.  
  69. pstext:    $(PSTEXT_OBJ)
  70.     $(CC) -o pstext $(PSTEXT_OBJ)
  71.  
  72. install: 
  73.     install -c -m755 -o bin -g bin pstext $(DEST)
  74. clean:    
  75.     rm -f $(PSTEXT_OBJ) pstext a.out core
  76. SHAR_EOF
  77. fi # end of overwriting check
  78. if test -f 'pstext.1'
  79. then
  80.     echo shar: will not over-write existing file "'pstext.1'"
  81. else
  82. cat << \SHAR_EOF > 'pstext.1'
  83. .TH PSTEXT 1 "December 12, 1989"
  84. .UC 4
  85. .SH NAME
  86. pstext \- convert plain text to PostScript
  87. .SH SYNOPSIS
  88. .B pstext
  89. [
  90. .B \-l
  91. ] [
  92. .B \-ld
  93. ] [
  94. .B \-p
  95. ] [
  96. .B \-d
  97. ] [
  98. .B \-s pointsize
  99. ] [
  100. .B \-f fontname
  101. ] [
  102. .B \-n numberoflines
  103. ] [
  104. .B \-t tabstring
  105. ] [
  106. .B \-i pointoffset
  107. ] [
  108. .B \-
  109. ] [ file ... ]
  110. .br
  111. .SH DESCRIPTION
  112. .I Pstext
  113. reads each
  114. .I file
  115. in sequence converts it from plain text to PostScript and writes it to 
  116. the standard output, if no files are specified it reads from the standard 
  117. input. Backspaces move the current point back the width
  118. of the underscore (_) in the current font and pointsize. Form feeds cause
  119. text to begin printing on a new page, in the case of dual page mode the
  120. next page may actually be on the same piece of paper. Separate files always
  121. begin on a new page. Tabs are set every width of the current tabstring
  122. (see -t option below).
  123. .PP
  124. A reasonable amount of care has been taken to keep the PostScript generated
  125. as generic as possible.
  126. .PP
  127. The Apple LaserWriter, one of the more common PostScript printers,
  128. has the following fonts available: (note: the fonts must be specified
  129. exactly as shown.)
  130. .PP
  131. .nf
  132. .na
  133. .ta 3i
  134. AvantGarde-Book    AvantGarde-BookOblique
  135. AvantGarde-Demi    AvantGarde-DemiOblique
  136. Bookman-Demi    Bookman-DemiItalic
  137. Bookman-Light    Bookman-LightItalic
  138. Courier    Courier-Bold
  139. Courier-BoldOblique    Courier-Oblique
  140. Helvetica    Helvetica-Bold
  141. Helvetica-BoldOblique    Helvetica-Narrow
  142. Helvetica-Narrow-Bold    Helvetica-Narrow-BoldOblique
  143. Helvetica-Narrow-Oblique    Helvetica-Oblique
  144. NewCenturySchlbk-Bold    NewCenturySchlbk-BoldItalic
  145. NewCenturySchlbk-Italic    NewCenturySchlbk-Roman
  146. Palatino-Bold    Palatino-BoldItalic
  147. Palatino-Italic    Palatino-Roman
  148. Symbol    Times-Bold
  149. Times-BoldItalic    Times-Italic
  150. Times-Roman    ZapfChancery-MediumItalic
  151. ZapfDingbats
  152. .fi
  153. .ad
  154. .PP
  155. The options are:
  156. .TP
  157. .B \-l
  158. Text will be displayed in landscape mode.
  159. .TP
  160. .B \-ld
  161. Text will be displayed in landscape and dual page mode.
  162. .TP
  163. .B \-d
  164. Text will be displayed in portrait and dual page mode.
  165. .TP
  166. .B \-p
  167. Text will be displayed in portrait mode (default).
  168. .TP
  169. .BI \-s " pointsize"
  170. Text will be displayed in the given pointsize (12 default). Fractional
  171. pointsizes are acceptable.
  172. .TP
  173. .BI \-f " fontname"
  174. Text will be displayed in the give font if available (Courier default).
  175. Any font may be specified, if the printer (or whatever is displaying the
  176. PostScript) can not find the font Courier will be used anyway. Fonts
  177. commonly available are Courier-Bold, Helvetica, Helvetica-Bold, Times-Roman
  178. Times-Bold, Times-Italic and Symbol. There are obviously more depending
  179. on your output device.
  180. .TP
  181. .BI \-i " pointoffset"
  182. Text will be offset
  183. .I pointoffset
  184. points from where text normally starts. Note: this does not mean from
  185. the edge of the page, there is an offset from there already.
  186. .TP
  187. .BI \-n " numberoflines"
  188. Text will be displayed with 
  189. .I numberoflines 
  190. per page. This takes precedence
  191. over -s flag.
  192. .TP
  193. .BI \-t " tabstring"
  194. Tabs will be the width of 
  195. .I tabstring
  196. in the current pointsize and font.
  197. The default tabstring is NNNNNNNN, meaning that tabstops are placed every
  198. width of 8 N's. Tabs will go to the nearest forward tab stop.
  199. .PP
  200. .SH "SEE ALSO"
  201. PostScript Language Reference Manual by Adobe Systems Inc.
  202. .SH BUGS
  203. In some systems (Next for example) findfont will look for fonts in more places 
  204. than just those that FontDirectory gives. In these cases pstext output 
  205. may not print in the desired font and will print in Courier instead. There
  206. are a couple of options in dealing with this. Modify the C code so the 
  207. line containing the FontDirectory is not sent, or some other command is
  208. used (SharedFontDirectory in the case of a Next). Or you can comment out
  209. the line in the PostScript output before you send it to the printer. Be
  210. warned that omitting the line all together will mean that if you specify
  211. a font that can't be found the job will not print.
  212.  
  213. The margins have been set to work for an Apple LaserWriter NTX these may
  214. need to be reset for devices whose margins differ.
  215. .SH AUTHOR
  216. Dan Judd, St. Olaf College.
  217.  
  218. This program is freely redistributable, and is not to be sold.
  219. SHAR_EOF
  220. fi # end of overwriting check
  221. if test -f 'pstext.c'
  222. then
  223.     echo shar: will not over-write existing file "'pstext.c'"
  224. else
  225. cat << \SHAR_EOF > 'pstext.c'
  226. /* 
  227.   pstext
  228.   by Dan Judd
  229.      St. Olaf College
  230.      11/29/89
  231.   
  232.   This program takes plain ascii text and converts it to Postscript.
  233.   It takes a few options.
  234.   [-p ] prints portrait mode 1 page (default)
  235.   [-l ] prints landscape mode 1 page
  236.   [-ld ] dual landscape mode 2 pages per page
  237.   [-d ] dual portrait mode, prints 2 pages per page
  238.   [-n number] number of lines per page
  239.   [-t tabstring ] use a different tabstring size (NNNNNNNN default)
  240.   [-f fontname ] use a different font (Courier default)
  241.   [-s pointsize ] use a different point size (12 default)
  242.   [-i pointoffset ] offset pointoffset points from normal (0 default)
  243.  
  244.   It handles tabs and backspaces in an intelligent way in any font.
  245.  
  246.   Copyright Dan Judd 1989
  247.   This program is freely redistributable, but may not be sold.
  248.   send bug fixes to danjudd@thor.acc.stolaf.edu
  249.  */
  250.  
  251. #include <stdio.h>
  252. #include <strings.h>
  253. #include <ctype.h>
  254. #define TRUE 1
  255. #define FALSE 0
  256. #define DFLT_PTSIZE 12
  257. #define DFLT_FONT "Courier"
  258. #define DFLT_TABSTRING "NNNNNNNN"
  259. #define INDENT 0
  260. #define DFLT_STYLE 1
  261. #define DFLT_LINES 0
  262.  
  263. main(argc,argv)
  264. int argc;
  265. char *argv[];
  266. {
  267.  double ptsize=DFLT_PTSIZE;
  268.  char *font;
  269.  char *tabstring;
  270.  int style=DFLT_STYLE;
  271.  int numlines=DFLT_LINES;
  272.  int indent=INDENT;
  273.  FILE *fpout=stdout;
  274.  FILE *fpin=stdin;
  275.  short badflag=FALSE;
  276.  char ch;
  277.  char *progname;
  278.  double atof();
  279.  
  280.  font=(char *) malloc(sizeof(DFLT_FONT));
  281.  strcpy(font,DFLT_FONT);
  282.  tabstring=(char *) malloc(sizeof(DFLT_TABSTRING));
  283.  strcpy(tabstring,DFLT_TABSTRING);
  284.  /* parse args */
  285.  progname=*argv++;
  286.  
  287.  while ((--argc > 0)&&(*argv[0]=='-')) {
  288.    switch(*++argv[0]) {
  289.     
  290.     case 'l':    if(*++argv[0]=='d') {
  291.           style=3;
  292.           }
  293.          else {
  294.           style=4;
  295.           };
  296.         break;
  297.     case 'p':    style=1;
  298.         break;
  299.     case 'd':    style=2;
  300.         break;
  301.     case 'f':    if (*++argv[0] !='\0'){
  302.           font=*argv;
  303.          }
  304.         else
  305.          if (--argc) {
  306.           font=*++argv;
  307.           }
  308.          else {
  309.           badflag=TRUE;
  310.           }
  311.         break;
  312.     case 't':    if (*++argv[0] !='\0'){
  313.           tabstring=*argv;
  314.          }
  315.         else
  316.          if (--argc) {
  317.           tabstring=*++argv;
  318.           }
  319.          else {
  320.           badflag=TRUE;
  321.           }
  322.         break;
  323.     case 'n':    if (*++argv[0] !='\0'){
  324.           if((numlines=atof(*argv)) <= 0){
  325.             fprintf(stderr,"specify a line number 1 or more\n");
  326.             badflag=TRUE;
  327.             }
  328.         }
  329.         else
  330.         if (--argc) {
  331.           if((numlines=atof(*++argv)) <= 0){
  332.             fprintf(stderr,"specify a line number 1 or more\n");
  333.             badflag=TRUE;
  334.             }
  335.           }
  336.          else {
  337.           badflag=TRUE;
  338.           }
  339.         break;
  340.     case 'i':    if (*++argv[0] !='\0'){
  341.           if((indent=atof(*argv)) <= 0){
  342.             fprintf(stderr,"specify a point offset of 1 or more\n");
  343.             badflag=TRUE;
  344.             }
  345.         }
  346.         else
  347.         if (--argc) {
  348.           if((indent=atof(*++argv)) <= 0){
  349.             fprintf(stderr,"specify a point offset of 1 or more\n");
  350.             badflag=TRUE;
  351.             }
  352.           }
  353.          else {
  354.           badflag=TRUE;
  355.           }
  356.         break;
  357.     case 's':    if (*++argv[0] !='\0'){
  358.           if((ptsize=atof(*argv)) <= 0){
  359.             fprintf(stderr,"specify a point size greater than 0\n");
  360.             badflag=TRUE;
  361.             }
  362.         }
  363.         else
  364.         if (--argc) {
  365.           if((ptsize=atof(*++argv)) <= 0){
  366.             fprintf(stderr,"specify a point size greater than 0\n");
  367.             badflag=TRUE;
  368.             }
  369.           }
  370.          else {
  371.           badflag=TRUE;
  372.           }
  373.         break;
  374.     default:    badflag=TRUE;
  375.         break;
  376.  
  377.     }
  378. if(badflag) {
  379.  fprintf(stderr,"Usage: %s [-p] [-l] [-ld] [-d] [-n lines ] [-t ",progname);
  380.  fprintf(stderr,"tabstring] [-f fontname] [-s pointsize] [-i point offset]");
  381.  fprintf(stderr,"[file1 ... ]\n");
  382.  exit(1);
  383.   }
  384.     *argv++;
  385.     }
  386.  
  387.  /* set up postscript header */
  388.  
  389.  printhead(fpout,font,ptsize,style,numlines,tabstring,indent);
  390.  /* read files */
  391.  if (argc ==0) {
  392.    getfile(stdin,fpout);
  393.    }
  394.   else {
  395.    while(argc--!=0) {
  396.     if((fpin=fopen(*argv,"r"))!=NULL) {
  397.       getfile(fpin,fpout);
  398.       fclose(fpin);
  399.       *argv++;
  400.       }
  401.      else{
  402.       fprintf(stderr,"Unable to open file %s\n",*argv);
  403.       fprintf(fpout,"\nlp\n");
  404.       exit(1);
  405.       }
  406.     }
  407.   }
  408.  /* makesure showpage is done so last page prints */
  409.  fprintf(fpout,"\nlp\n");
  410.  exit(0);
  411.  }
  412.  
  413.  /*
  414.    getfile(fpin,fpout)
  415.     FILE *fpin,fpout;
  416.    Read in text from a file and output appropriate postscript
  417.   */
  418.  getfile(fpin,fpout)
  419.   FILE *fpin,*fpout;
  420.   {
  421.    char ch;
  422.  
  423.    fprintf(fpout,"(");
  424.    while ((ch=getc(fpin))!=EOF) {
  425.    if(isprint(ch)) {
  426.     switch (ch ) {
  427.      case '(':
  428.      case ')':
  429.      case '\\':
  430.         fprintf(fpout,"\\%c",ch);
  431.         break;
  432.      default:    fprintf(fpout,"%c",ch);
  433.         break;
  434.      }
  435.    }
  436.   else {
  437.     switch (ch ) {
  438.      case '\n':    fprintf(fpout,")s\n(");
  439.         break;
  440.      case '\t':    fprintf(fpout,")S\nht (");
  441.         break;
  442.      case '\b':    fprintf(fpout,")S\nbs(");
  443.         break;
  444.      case '\r':    fprintf(fpout,")S\ncr(");
  445.         break;
  446.      case '\f':    fprintf(fpout,")S\nnp(");
  447.         break;
  448.      default:
  449.         break;
  450.         }
  451.       }
  452.    }
  453.  /* send trailer */
  454.  fprintf(fpout,")s\nnp\n");
  455.  }
  456. printhead(fp,font,size,style,numlines,tabstring,indent)
  457.  FILE *fp;
  458.  char *font;
  459.  double size;
  460.  int style;
  461.  int numlines;
  462.  char *tabstring;
  463.  int indent;
  464.  {
  465.   fprintf(fp,"%%! PS - Adobe\n");
  466.   fprintf(fp,"%% Created by pstext by Dan Judd\n");
  467.   fprintf(fp,"/PAGE_STYLE %d def\n",style);
  468.   fprintf(fp,"/NUM_LINES %d def\n",numlines);
  469.   fprintf(fp,"/FONT (%s) cvn def\n",font);
  470.   fprintf(fp,"/FONT_SIZE %lf def\n",size);
  471.   fprintf(fp,"%%check if font exists\n");
  472.  
  473. /* this is vaguely device depenent, FontDirectory is standard, but */
  474. /* the Next uses SharedFontDirectory instead. The program won't crash,*/
  475. /* but the only font you can use is Courier. Blech. */
  476. /* if this is a problem just comment out the next line */
  477.  
  478.   fprintf(fp,"FontDirectory FONT known not { /FONT (Courier) cvn def} if\n");
  479.   fprintf(fp,"%%misc hardware defs\n");
  480.   if (style > 2) {
  481.     fprintf(fp,"/XLMARGIN 18 def\n");
  482.     }
  483.    else
  484.     {
  485.     fprintf(fp,"/XLMARGIN %d def\n",(indent+18));
  486.     }
  487.   fprintf(fp,"/XRMARGIN 14 def\n");
  488.   fprintf(fp,"/XPAGE 612 def\n");
  489.   fprintf(fp,"/YPAGE 792 def\n");
  490.   fprintf(fp,"/YTMARGIN 8 def\n");
  491.   if (style < 3) {
  492.     fprintf(fp,"/YBMARGIN 13 def\n");
  493.     }
  494.    else
  495.     {
  496.     fprintf(fp,"/YBMARGIN %d def\n",(indent+13));
  497.     }
  498.   fprintf(fp,"/PAGENUM 1 def\n");
  499.   fprintf(fp,"%%\n");
  500.   fprintf(fp,"%%short defs to save space\n");
  501.   fprintf(fp,"%%\n");
  502.   fprintf(fp,"/bd {bind def} bind def\n");
  503.   fprintf(fp,"/m {moveto} bd\n");
  504.   fprintf(fp,"/l {lineto}bd\n");
  505.   fprintf(fp,"/gs {gsave}bd\n");
  506.   fprintf(fp,"/gr {grestore}bd\n");
  507.   fprintf(fp,"/tr {translate} bd\n");
  508.   fprintf(fp,"/rt {rotate} bd\n");
  509.   fprintf(fp,"%%\n");
  510.   fprintf(fp,"%%Set up vars and np depending on PAGE_STYLE\n");
  511.   fprintf(fp,"%%\n");
  512.   fprintf(fp,"%% Style 1\n");
  513.   fprintf(fp,"1 PAGE_STYLE eq {\n");
  514.   fprintf(fp,"    /PAGES_PER_SHEET 1 def\n");
  515.   fprintf(fp,"    /sp {/SAVEOBJ save def} def\n");
  516.   fprintf(fp,"    /np { showpage SAVEOBJ restore sp bp } bd\n");
  517.   fprintf(fp,"    } if\n");
  518.   fprintf(fp,"%% Style 2\n");
  519.   fprintf(fp,"2 PAGE_STYLE eq {\n");
  520.   fprintf(fp,"    /PAGES_PER_SHEET 2 def\n");
  521.   fprintf(fp,"    /sp {/SAVEOBJ save def gs XPAGE 2 div dup 0 m YPAGE l stroke\n");
  522.   fprintf(fp,"        newpath 0 0 m 0 YPAGE l XPAGE 2 div XRMARGIN sub dup\n");
  523.   fprintf(fp,"        YPAGE l 0 l 0 0 l clip\n");
  524.   fprintf(fp,"        } bd\n");
  525.   fprintf(fp,"    /np { /PAGENUM 1 PAGENUM add def\n");
  526.   fprintf(fp,"        PAGENUM PAGES_PER_SHEET\n");
  527.   fprintf(fp,"        gt {gr showpage SAVEOBJ restore sp /PAGENUM 1 def }\n");
  528.   fprintf(fp,"        {gr gs XPAGE 2 div 0 tr} ifelse\n");
  529.   fprintf(fp,"        bp\n");
  530.   fprintf(fp,"        } bd\n");
  531.   fprintf(fp,"    } if\n");
  532.   fprintf(fp,"%% Style 3\n");
  533.   fprintf(fp,"3 PAGE_STYLE eq {\n");
  534.   /* define if you want double page landscape mode to have fonts */
  535.   /* proportional to single page portrait */
  536. #ifdef LANDPROP
  537.   fprintf(fp,"    /FONT_SIZE FONT_SIZE .642 mul def\n");
  538. #endif
  539.   fprintf(fp,"    /TMP XPAGE def\n");
  540.   fprintf(fp,"    /XPAGE YPAGE def\n");
  541.   fprintf(fp,"    /YPAGE TMP def\n");
  542.   fprintf(fp,"    /TMP XRMARGIN def\n");
  543.   fprintf(fp,"    /XRMARGIN YTMARGIN def\n");
  544.   fprintf(fp,"    /YTMARGIN TMP def\n");
  545.   fprintf(fp,"    /TMP XLMARGIN def\n");
  546.   fprintf(fp,"    /XLMARGIN YBMARGIN def\n");
  547.   fprintf(fp,"    /YBMARGIN TMP def\n");
  548.   fprintf(fp,"    /PAGES_PER_SHEET 2 def\n");
  549.   fprintf(fp,"    /sp {/SAVEOBJ save def gs 0 XPAGE tr -90 rt\n");
  550.   fprintf(fp,"        XPAGE 2 div dup 0 moveto YPAGE l stroke\n");
  551.   fprintf(fp,"        newpath 0 0 m 0 YPAGE l XPAGE 2 div XRMARGIN sub dup\n");
  552.   fprintf(fp,"        YPAGE l 0 l 0 0 l clip\n");
  553.   fprintf(fp,"        } bd\n");
  554.   fprintf(fp,"    /np { /PAGENUM 1 PAGENUM add def\n");
  555.   fprintf(fp,"        PAGENUM PAGES_PER_SHEET\n");
  556.   fprintf(fp,"        gt {gr showpage SAVEOBJ restore sp /PAGENUM 1 def }\n");
  557.   fprintf(fp,"        {gr gs 0 XPAGE 2 div tr -90 rt } ifelse\n");
  558.   fprintf(fp,"        bp\n");
  559.   fprintf(fp,"        } bd\n");
  560.   fprintf(fp,"    } if\n");
  561.   fprintf(fp,"%% Style 4\n");
  562.   fprintf(fp,"4 PAGE_STYLE eq {\n");
  563.   fprintf(fp,"    /TMP XPAGE def\n");
  564.   fprintf(fp,"    /XPAGE YPAGE def\n");
  565.   fprintf(fp,"    /YPAGE TMP def\n");
  566.   fprintf(fp,"    /TMP XRMARGIN def\n");
  567.   fprintf(fp,"    /XRMARGIN YTMARGIN def\n");
  568.   fprintf(fp,"    /YTMARGIN TMP def\n");
  569.   fprintf(fp,"    /TMP XLMARGIN def\n");
  570.   fprintf(fp,"    /XLMARGIN YBMARGIN def\n");
  571.   fprintf(fp,"    /YBMARGIN TMP def\n");
  572.   fprintf(fp,"    /PAGES_PER_SHEET 1 def\n");
  573.   fprintf(fp,"    /sp {/SAVEOBJ save def gs 0 XPAGE tr -90 rt\n");
  574.   fprintf(fp,"        } bd\n");
  575.   fprintf(fp,"    /np { gr showpage SAVEOBJ restore sp bp} bd\n");
  576.   fprintf(fp,"    } if\n");
  577.   fprintf(fp,"%%\n");
  578.   fprintf(fp,"%%set up fonts\n");
  579.   fprintf(fp,"%%\n");
  580.   fprintf(fp,"NUM_LINES 1 ge {FONT findfont 1 scalefont setfont\n");
  581.   fprintf(fp,"    /FONT_HT currentfont /FontBBox get 3 get 0 exch\n");
  582.   fprintf(fp,"        currentfont /FontMatrix get transform exch pop\n");
  583.   fprintf(fp,"        currentfont /FontBBox get 0 get 0 exch\n");
  584.   fprintf(fp,"        currentfont /FontMatrix get transform exch pop\n");
  585.   fprintf(fp,"        sub def\n");
  586.   fprintf(fp,"    /TMP FONT_HT 1 sub def\n");
  587.   fprintf(fp,"    /FONT_SIZE YPAGE YBMARGIN sub YTMARGIN sub 1 sub dup\n");
  588.   fprintf(fp,"    NUM_LINES div TMP mul sub NUM_LINES div def\n");
  589.   fprintf(fp,"    } if\n");
  590.   fprintf(fp,"FONT findfont FONT_SIZE scalefont setfont\n");
  591.   fprintf(fp,"%%get height of font set tolerances\n");
  592.   fprintf(fp,"/FONT_HT currentfont  /FontBBox get 3 get 0 exch\n");
  593.   fprintf(fp,"    currentfont  /FontMatrix get transform exch pop\n");
  594.   fprintf(fp,"    currentfont  /FontBBox  get 0 get 0 exch\n");
  595.   fprintf(fp,"    currentfont  /FontMatrix get transform exch pop\n");
  596.   fprintf(fp,"    sub  def\n");
  597.   fprintf(fp,"/FONT_TOL FONT_HT YBMARGIN add def\n");
  598.   fprintf(fp,"%%\n");
  599.   fprintf(fp,"%%Routines common to all page styles\n");
  600.   fprintf(fp,"%%\n");
  601.   fprintf(fp,"/bp { XLMARGIN YPAGE YTMARGIN sub FONT_SIZE sub m\n");
  602.   fprintf(fp,"    } bd\n");
  603.   fprintf(fp,"/s { show  currentpoint exch pop dup FONT_TOL\n");
  604.   fprintf(fp,"    gt {FONT_SIZE sub XLMARGIN  exch m} {np} ifelse}  bd\n");
  605.   fprintf(fp,"/S {show} bd\n");
  606.   fprintf(fp,"/OFFSET (_) stringwidth pop neg def\n");
  607.   fprintf(fp,"/bs { OFFSET 0 rmoveto } bd\n");
  608.   fprintf(fp,"/bs {XLMARGIN currentpoint pop OFFSET add lt {OFFSET 0 rmoveto}");
  609.   fprintf(fp,"{XLMARGIN currentpoint exch pop m}ifelse} bd");
  610.   fprintf(fp,"/TABLEN (%s) stringwidth pop def\n",tabstring);
  611.   fprintf(fp,"/ht {currentpoint exch XLMARGIN sub TABLEN div cvi 1 add TABLEN\n");
  612.   fprintf(fp,"    mul XLMARGIN add exch m}bd\n");
  613.   fprintf(fp,"/cr {currentpoint XLMARGIN exch m pop} bd\n");
  614.   fprintf(fp,"/lp {gr 1 PAGENUM ne {showpage}if} bd\n");
  615.   fprintf(fp,"%%\n");
  616.   fprintf(fp,"%%begin data et al\n");
  617.   fprintf(fp,"%%\n");
  618.   fprintf(fp,"sp\n");
  619.   fprintf(fp,"bp\n");
  620.  }
  621. SHAR_EOF
  622. fi # end of overwriting check
  623. #    End of shell archive
  624. exit 0
  625.  
  626.